package com.vip8.recorder.api.model.base;

import lombok.Data;

@Data
public class SingleResult<T> extends Result {
    /**
     * 需要传递的数据
     */
    private T data;

    public SingleResult() {

    }

    public SingleResult(T data) {
        super(SUCCESS_CODE, true, "");
        this.data = data;

    }

    public SingleResult(int code, boolean success, String message) {
        super(code, success, message);
    }

    public SingleResult(int code, boolean success, String message, T data) {
        super(code, success, message);
    }

    public static SingleResult success() {
        return new SingleResult(null);
    }

    public static <T> SingleResult<T> success(T data) {
        return new SingleResult(data);
    }

    public static <T> SingleResult<T> failure(int code, String message) {
        return new SingleResult(code, false, message, null);
    }

    public static <T> SingleResult<T> failure(String message) {
        return new SingleResult(FAIL_CODE, false, message, null);
    }

    public static SingleResult failure() {
        return new SingleResult(FAIL_CODE, false, FAIL_DEFAULT_MESSAGE, null);
    }
}
